package cn.edu.ujn.booksshop.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.booksshop.dao.CartDetail;
import cn.edu.ujn.booksshop.dao.ShoppingCart;
import cn.edu.ujn.booksshop.dao.ShoppingCartMapper;
import cn.edu.ujn.util.Page;

@Service
@Transactional
public class ShoppingCartServiceImpl implements IShoppingCartService {

	@Autowired
	private ShoppingCartMapper shoppingDao;
	
	@Override
	public int deleteByPrimaryKey(Integer cartid) {
		int key = shoppingDao.deleteByPrimaryKey(cartid);
		// TODO Auto-generated method stub
		return key;
	}

	@Override
	public int insert(ShoppingCart row) {
		// TODO Auto-generated method stub
		int insert = shoppingDao.insert(row);
		return insert;
	}

	@Override
	public int insertSelective(ShoppingCart row) {
		int insertSelective = shoppingDao.insertSelective(row);
		// TODO Auto-generated method stub
		return insertSelective;
	}

	@Override
	public ShoppingCart selectByPrimaryKey(Integer cartid) {
		ShoppingCart cart = shoppingDao.selectByPrimaryKey(cartid);
		// TODO Auto-generated method stub
		return cart;
	}

	@Override
	public int updateByPrimaryKeySelective(ShoppingCart row) {
		// TODO Auto-generated method stub
		
		int update = shoppingDao.updateByPrimaryKeySelective(row);
		return update;
	}

	@Override
	public int updateByPrimaryKey(ShoppingCart row) {
		// TODO Auto-generated method stub
		int key = shoppingDao.updateByPrimaryKey(row);
		return key;
	}
	
	@Override
	public Page<ShoppingCart> selectAll(Integer page,Integer rows) {
		// TODO Auto-generated method stub
		List<ShoppingCart> list = this.shoppingDao.selectAll((page-1)*rows,rows);
		Page<ShoppingCart> pages = new Page<ShoppingCart>();
		pages.setPage(page);
		pages.setRows(list);
		pages.setSize(rows);
		pages.setTotal(100);
		return pages;
	}

}
